﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using GMigrate.Properties;
using System.Windows.Controls;

namespace GMigrate
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            Settings.Default.Save();
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            EventManager.RegisterClassHandler(typeof(TextBox),
                  TextBox.GotFocusEvent,
                  new RoutedEventHandler(TextBox_GotFocus));
            EventManager.RegisterClassHandler(typeof(PasswordBox),
                  TextBox.GotFocusEvent,
                  new RoutedEventHandler(TextBox_GotFocus));
            base.OnStartup(e);
        }

        void TextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            if (sender is TextBox)
                (sender as TextBox).SelectAll();

            if (sender is PasswordBox)
                (sender as PasswordBox).SelectAll();
        }
    }
}
